package com.ling.sdk.glide

import android.graphics.drawable.Drawable
import com.bumptech.glide.annotation.GlideExtension
import com.bumptech.glide.load.resource.bitmap.TransformationUtils.fitCenter
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.annotation.GlideOption


@GlideExtension
object MyAppExtension {


    private const val MINI_THUMB_SIZE = 100

    @GlideOption
    @JvmStatic
    fun miniThumb(options: RequestOptions) {
        options.fitCenter().override(MINI_THUMB_SIZE)
    }

    @GlideOption
    @JvmStatic
    fun defaultIcon(options: RequestOptions, resourceId: Int) {
        options.error(resourceId).placeholder(resourceId).fallback(resourceId)
    }

    @GlideOption
    @JvmStatic
    fun defaultIcon(options: RequestOptions, resourceDrawable: Drawable) {
        options.error(resourceDrawable).placeholder(resourceDrawable).fallback(resourceDrawable)
    }
}